<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="timer"></div>
</body>
<script>
    /**
     * 在timer中显示倒计时十秒钟
     * 时间到0时,跳转到百度的首页
    */
    var timer = document.getElementById("timer");
    var count = 10;
    var timerId = setInterval(function(){
        timer.innerHTML = count + "秒后跳转到百度..."; 
        count = count - 1;   
        if(count == 0){
            clearInterval(timerId);
            window.location.href = "http://www.baidu.com";
        }    
    },1000);
</script>
</html>